﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Micro.Core.ApiConsumer.ActionAttributes;

namespace Micro.Core.ApiConsumer.Context
{
    /// <summary>
    /// 接口请求相关的描述
    /// </summary>
    public class ApiActionDescriptor:ICloneable
    {
        /// <summary>
        /// 接口名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 接口的action特性，包括host、route等
        /// </summary>
        public ApiActionAttribute[] Attributes { get; set; }

        /// <summary>
        /// 参数描述
        /// </summary>
        public ApiParameterDescriptor[] Parameters { get; set; }

        /// <summary>
        /// 接口返回类型
        /// </summary>
        public Type Return { get; set; }

        /// <summary>
        /// 克隆对象
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            return new ApiActionDescriptor
            {
                Name = this.Name,
                Attributes = this.Attributes,
                Parameters = this.Parameters.Select(item=>(ApiParameterDescriptor)item.Clone()).ToArray(),
                Return = this.Return
            };
        }
    }
}
